home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11850 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  61 lines

  1. Path: ix.netcom.com!netnews
  2. From: jlilley@ix.netcom.com (John Lilley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: linking C & C++
  5. Date: 16 Mar 1996 16:49:18 GMT
  6. Organization: Nerds for Hire, Inc.
  7. Distribution: world
  8. Message-ID: <4ieree$dqv@cloner3.netcom.com>
  9. References: <4ibsla$pll@news.onramp.net>
  10. NNTP-Posting-Host: den-co12-24.ix.netcom.com
  11. Mime-Version: 1.0
  12. Content-Type: Text/Plain; charset=US-ASCII
  13. X-NETCOM-Date: Sat Mar 16  8:49:18 AM PST 1996
  14. X-Newsreader: WinVN 0.99.7
  15.  
  16. In article <4ibsla$pll@news.onramp.net>, dean@onramp.net says...
  17. >
  18. >I'm doing some work on a system that now requires me to do a longjmp from a C 
  19. >program back into a C++ program.  The whole thing is linked into one big 
  20. >executable.  I am having some trouble getting the thing linked, and I have 
  21. >tried a number of different combinations.  What I have is a signal(), and 
  22. >alarm(), and a longjmp() in the C file, and a setjmp() in the C++ file.  I have 
  23. >tried defining the jmpbuffer in both files with it as an exter in the other, 
  24. >but the linker always gives me a not-found condition for the jmpbuffer.
  25.  
  26. Not seeing the code, I can only guess, but its probably the C/C++ name
  27. decoration problem:
  28.  
  29. try this:
  30.  
  31. // header.h
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. extern jmp_buf myJumpBuffer;
  37.  
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41.  
  42.  
  43. //source1.c
  44. #include "header.h"
  45. jmp_buf myJumpBuffer;
  46.  
  47. // source2.cpp
  48. #include "header.h"
  49.  
  50.  
  51. Hope it helps.
  52.  
  53. john lilley
  54.  
  55. =========================================================================
  56. ||  John Lilley                                    phone: 303-415-1860 ||
  57. ||  Nerds for Hire, Inc.                             fax: 303-415-1923 ||
  58. ||  "Nerds for all seasons"                      jlilley@ix.netcom.com ||
  59. =========================================================================
  60.  
  61.